package deom3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-04-06
 * Time: 22:50
 */
import java.util.*;
class ListNode {
    int val;
    ListNode next;
    public ListNode(int val){
        this.val = val;
    }
}
public  class test13{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        scan.nextLine();
        String nodeValue = scan.nextLine();
        String[] nodes = nodeValue.split(" ");
        ListNode dummyHead = new ListNode(-1);
        ListNode tail = dummyHead;
        for (int i = 0; i < n; i++) {
            ListNode node = new ListNode(Integer.parseInt(nodes[i]));
            tail.next = node;
            tail = node;
        }
        String part = scan.nextLine();
        int left = Integer.parseInt(part.split(" ")[0]);
        int right = Integer.parseInt(part.split(" ")[1]);
        ListNode newHead = reverseBetween(dummyHead.next,left,right);
        while (newHead != null){
            System.out.print(newHead.val + " ");
            newHead = newHead.next;
        }

    }

    private static ListNode reverseBetween(ListNode head, int l, int r) {
        ListNode dummyHead = new ListNode(-1);
        dummyHead.next = head;
        ListNode pre = dummyHead;
        for (int i = 1; i < l; i++) {
            pre = pre.next;
        }
        ListNode cur = pre.next;
        for (int i = l; i < r; i++) {
            ListNode tmp = cur.next;
            cur.next = tmp.next;
            tmp.next = pre.next;
            pre.next = tmp;
        }
        return  dummyHead.next;

    }
}